/* eslint valid-jsdoc: "off" */

"use strict";

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1677143156239_5596";

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  //关闭CSRF跨域验证
  config.security = {
    csrf: {
      enable: false,
    },
  };

  //配置egg-cors解决跨域
  exports.cors = {
    origin: "*",
    allowMethods: "GET,POST",
    credential: true,
  };

  //mysql配置
  exports.mysql = {
    client: {
      host: "127.0.0.1",
      port: "3306",
      user: "root",
      password: "123456",
      database: "examdb",
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  exports.cluster = {
    listen: {
      port: 7001,
      hostname: "127.0.0.1", // 不建议设置 hostname 为 '0.0.0.0'，它将允许来自外部网络和来源的连接，请在知晓风险的情况下使用
      // path: '/var/run/egg.sock',
    },
  };

  /*   //配置访问静态资源
  config.static = {
    prefix: "/public",
    dir: path.join(appInfo.baseDir, "/public"), // `String` or `Array:[dir1, dir2, ...]` 静态化目录,可以设置多个静态化目录
    dynamic: true, // 如果当前访问的静态资源没有缓存，则缓存静态文件，和`preload`配合使用；
    preload: false,
    maxAge: 31536000, // in prod env, 0 in other envs
    buffer: true, // in prod env, false in other envs
  }; */

  return {
    ...config,
    ...userConfig,
  };
};
